<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	
	<h:form id="modalityDataForm" style="height:95%;width:100%;" prependId="false"> 
		<h:panelGrid columns="2" cellpadding="2" columnClasses="top-align,top-align" style="min-height:90%;width:100%"  > 
			<h:column>
				<h:panelGrid columns="2" cellpadding="2" > 
		            <h:outputLabel value="#{msgs.Name} :" for="modalityName" />
		            <p:inputText id="modalityName"     value="#{modalityBean.modality.name}" maxlength ="20" size="20" required="true" requiredMessage="#{msgs.ModalityNameObligatory}"/>
		
		            <h:outputLabel value="#{msgs.ModalityType} :" for="modalityType" />
		            <p:selectOneMenu id="modalityType" value="#{modalityBean.modality.trainingType}" converter="#{ttConverter}" valueChangeListener="#{modalityBean.onTrainingTypeChange}"   >
		            	<f:selectItems value="#{modalityBean.trainingTypes}"  var="trainingType" itemLabel="#{msgs[trainingType.name]}" itemValue="#{trainingType}" />
						<p:ajax listener="#{modalityBean.trainingTypeChanged }" update="panelExecutionTypes, panelVolumes, @this " />
		            </p:selectOneMenu>
		
					<h:outputLabel value="#{msgs.Description} :" for="modalityDescription" />
					<p:inputTextarea id="modalityDescription" rows="4" cols="50" immediate="true"
						counter="counter" maxlength="180"
						counterTemplate="{0} #{msgs.CharsRemaining}" autoResize="false"
						value="#{ modalityBean.modality.description}">
						<p:ajax event="change" update="@this"  />
					</p:inputTextarea>
					<p:spacer />
					<h:outputText id="counter" />
	
					<h:outputLabel 	value="#{msgs.Version} :"		for="modalityVersion"  />
					<p:selectOneMenu id="modalityVersion" value="#{modalityBean.modality}" converter="#{genericConverter}"  valueChangeListener="#{modalityBean.onVersionChanged}"  >
						<f:selectItems value="#{modalityBean.versionableModality.modalityVersions}" var="modalityVersion" 
							itemLabel="#{modalityVersion.version}" itemValue="#{modalityVersion}"/>
						<p:ajax  update=":content " />
					</p:selectOneMenu>
					
				
					<h:outputLabel 	value="#{msgs.Library} :"		for="modalityLibrary" rendered="#{modalityBean.modality.id == null}" />
					<p:selectOneMenu id="modalityLibrary" value="#{modalityBean.versionableModality.library}"	  rendered="#{modalityBean.modality.id == null}" converter="#{libraryConverter}">
		            	<f:selectItems value="#{modalityBean.activeUser.librarys}" var="library" itemLabel="#{library.name}" itemValue="#{library}"  />
					</p:selectOneMenu>
	
					<h:outputLabel 	value="#{msgs.Library} :"		for="modalitySavedLibrary" rendered="#{modalityBean.modality.id != null}"  />
					<p:inputText id="modalitySavedLibrary" value="#{modalityBean.versionableModality.library.name}"  disabled="true" rendered="#{modalityBean.modality.id != null}" />
										
					<h:outputLabel 	value="#{msgs.CreatedAt} :"		for="modalityCreatedAt" rendered="#{modalityBean.modality.id != null}" />
					<p:inputText  	id="modalityCreatedAt" 	value="#{modalityBean.modality.createdAt}" disabled="true" rendered="#{modalityBean.modality.id != null}"  >
						<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" rendered="#{modalityBean.modality.id != null}" />
					</p:inputText>
		
					<h:outputLabel 	value="#{msgs.ChangedAt} :"		for="modalityChangedAt" rendered="#{modalityBean.modality.id != null}" />
					<p:inputText  	id="modalityChangedAt" 	value="#{modalityBean.modality.lastChange}" disabled="true"  rendered="#{modalityBean.modality.id != null}">
						<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
					</p:inputText>

				</h:panelGrid>			
				<div align="left" style="position:absolute;bottom:0;left:0;" >
					<p:outputPanel layout="block" rendered="#{modalityBean.modality != null}">
						<p:commandButton id="saveButton"  	value="#{msgs.Save}"		actionListener="#{modalityBean.saveModality}"  				
							ajax="true"	update=":growl,:listModalityForm, :content"		icon="ui-icon-disk"		rendered="#{modalityBean.modality.id != null}" />
						<p:commandButton id="createButton" 	value="#{msgs.Create}"	actionListener="#{modalityBean.createModality}"		process=":tabModality:modalityDataForm" 
							ajax="true"	update=":growl,:listModalityForm, :content"		icon="ui-icon-document"	rendered="#{modalityBean.modality.id == null}" />
						<p:spacer width="50px"/>	
						<p:commandButton  value="#{msgs.Cancel}" update=":growl,:content"	action="#{modalityBean.cancelChange}"	icon="ui-icon-cancel"/>
					</p:outputPanel>
				</div>	 
			</h:column>
			<h:column>
				<p:panel id="panelExecutionTypes" header="#{msgs.ExecutionsTypes}" style="margin-left:100px;width:500px">
					<p:pickList id="pickExecution" value="#{modalityBean.executions}" var="execution"  required="true" requiredMessage="#{msgs.AtLeastOneExecutionIsRequired}"
						itemLabel="#{msgs[execution.name]}" itemValue="#{execution}" converter="#{genericConverter}">
						 <p:ajax event="transfer" update=":growl,pickExecution" listener="#{modalityBean.onChangeExecution}" />
					</p:pickList>
					<p:commandButton value="#{msgs.DefaultIntensityZones}" actionListener="#{modalityBean.toIntensityModality}" process="@parent" update=":modalityID,:growl"   />
				</p:panel>
				<p:panel id="panelVolumes" header="#{msgs.Volumes}" style="margin-left:100px;margin-top:10px;width:500px">
					<p:pickList id="pickVolumes" value="#{modalityBean.volumes}" var="volume"   required="true" requiredMessage="#{msgs.AtLeastOneVolumeIsRequired}"
						itemLabel="#{msgs[volume.name]}" itemValue="#{volume}" converter="#{genericConverter}"  >
						 <p:ajax event="transfer" listener="#{modalityBean.onChangeVolume}" />
					</p:pickList>
				</p:panel>
			</h:column>
		</h:panelGrid>		
	</h:form>
</html>